﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CalculatorApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string sel;
            double num1;
            double num2;
            double result=0;
                Console.Write("请输入第一个数： ");
                sel = Console.ReadLine();
                num1 = Double.Parse(sel);
                Console.Write("请输入第二个数： ");
                sel = Console.ReadLine();
                num2 = Double.Parse(sel);
                Console.Write("请输入运算符(+ - * /):");
                sel = Console.ReadLine();
                    switch (sel)
                    {
                        case "+":
                            result = num1 + num2;
                            break;
                        case "-":
                            result = num1 - num2;
                            break;
                        case "*":
                            result = num1 * num2;
                            break;
                        case "/":
                            if (num2 == 0)
                            {
                                Console.Write("除数不能为零");
                                Console.ReadKey();
                                return;
                            }
                            else result = num1 / num2;
                            break;
                    default:
                        Console.Write("运算符有误");
                        Console.ReadKey();
                        return;
                    }
                Console.WriteLine("运算结果：" + num1 + sel + num2 + "=" + result);
                Console.ReadLine();
            }
    }
}
